package com.flyou.ccnucenter.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;


import com.flyou.ccnucenter.widget.photoview.PhotoView;

import java.util.ArrayList;

/**
 * ============================================================
 * 项目名称：ChildDevelopmentAssistant
 * 包名称：com.e1858.childassistant.adapter
 * 文件名：LostFoundDetialGalleryAdapter
 * 类描述：
 * 创建人：flyou
 * 邮箱：fangjaylong@gmail.com
 * 创建时间：2015/12/22 11:22
 * 修改备注：
 * 版本：@version  V1.0
 * ============================================================
 */
public class LostFoundDetialGalleryAdapter extends PagerAdapter {
    private ArrayList<String> photos;
    private Context context;

    public LostFoundDetialGalleryAdapter(Context context, ArrayList<String> photos) {
        this.photos = photos;
        this.context = context;
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    @Override
    public int getCount() {
        return photos.size();
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        ImageView view = (ImageView) object;
        container.removeView(view);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        PhotoView photoView = new PhotoView(container.getContext());
        photoView.setImageUri(photos.get(position));
        container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        return photoView;
    }
}

